var rol;
function dajRolu(korisnik)
{
	
	var req = createRequest(); // defined above
	//Create the callback:
	req.onreadystatechange = function() {
	if (req.readyState != 4) return "error"; // Not there yet
	if (req.status != 200) {
	 // Handle request failure here...
	 return "error";
	}
	// Request successful, read the response
	var resp = req.responseXML.getElementsByTagName("naziv");
	rol=resp[0].childNodes[0].nodeValue;
	// ... and use it as needed by your app.
	return;
	};
	req.open("GET","korisno/roles/moje/?korisnik="+korisnik, false);
	req.send();
}
function usmjeri(korisnik)
{
	var req = createRequest(); // defined above
	//Create the callback:
	req.onreadystatechange = function() {
	if (req.readyState != 4) return; // Not there yet
	if (req.status != 200) {
	 // Handle request failure here...
	 return;
	}
	// Request successful, read the response
	var n = req.responseText;
	// ... and use it as needed by your app.
	if(n<1){
		alert('Nije vam dodjeljena niti jedna rola, kontaktirajte administratora!');
	}else if(n==1)
		{
		dajRolu(korisnik);
		window.location=(rol+".html");
		}
	else
		{
		window.location="pristup.html";
		}
	return;
	};
	req.open("GET","korisno/roles/broj/?korisnik="+korisnik, true);
	req.send();
}